package com.rejuvee.myloginapplication.ui.login;

import androidx.annotation.Nullable;

/**
 * 登陆表单状态，验证当前用户名或者密码是否格式正确
 */
public class LoginFormState {
    // 用户名输入错误的提示
    @Nullable
    private final Integer usernameError;
    // 密码输入错误的提示
    @Nullable
    private final Integer passwordError;
    // 是否都通过表单验证
    private final boolean isDataValid;

    /**
     * 构造器：创建一个验证不通过的提示
     * <p>
     * 账号 或 密码 错误
     *
     * @param usernameError 账号错误字符串资源ID
     * @param passwordError 密码错误字符串资源ID
     */
    public LoginFormState(@Nullable Integer usernameError, @Nullable Integer passwordError) {
        this.usernameError = usernameError;
        this.passwordError = passwordError;
        this.isDataValid = false;
    }

    /**
     * 构造器：创建一个验证通过的提示
     */
    public LoginFormState() {
        this.usernameError = null;
        this.passwordError = null;
        this.isDataValid = true;
    }

    @Nullable
    Integer getUsernameError() {
        return usernameError;
    }

    @Nullable
    Integer getPasswordError() {
        return passwordError;
    }

    boolean isDataValid() {
        return isDataValid;
    }
}